#include "WorkerAnt.h"
#include "SBWander.h"
#include "SBSeek.h"
#include "SBSeparation.h"
#include "Game.h"
#include "TextureManager.h"

#include "FoodSource.h"

#include "FoodSearchState.h"
#include <random>
#include "Timer.h"
#include <time.h>

#include <GL\glut.h>

WorkerAnt::WorkerAnt(Vec3f pos, float mass, int id) : m_foodSighted(false)
{
	m_pos = pos;
	m_invMass = 1/mass;
	m_id = id;
	m_texPath = "AntTexture.png";
	


	TheGame::Instance()->AddGameObject(id, this);

	SetAIState(new FoodSearchState(this));
	
	int xVel; 
	int zVel; 
	xVel = rand() % 6 -3;
	zVel = rand() % 6 -3;

	while(xVel == 0 && zVel == 0)
	{
		xVel = rand() % 6 -3;
		zVel = rand() % 6 -3;
	}


	SetVel(Vec3f(xVel, 0, zVel));

	

}

void WorkerAnt::Update()
{
	DecideBehaviour();
	
}

void WorkerAnt::Draw()
{
	
	glPushMatrix();

		
		glTranslatef(m_pos.X, m_pos.Y, m_pos.Z);

		TheTextureManager::Instance()->DrawTexture(m_texPath);


		glutSolidSphere(0.5f, 8, 8);
		Vec3f rearVec = (m_vel.NormaliseReturn() * -1) * 1.25;
		glTranslatef(rearVec.X, rearVec.Y, rearVec.Z);
		glutSolidSphere(0.75f, 8,8);
	
	
		if(m_debugDrawForces)
		{
			m_pAIState->DebugDrawForces();
		}

	glPopMatrix();

	


}